import request from '@/utils/request.js'

//将针对Admin的所有请求封装到一个对象里面
const adminApi = {
    list(adminQuery) {
        return request.get('/admin/list', {params: adminQuery})
    },
    deleteById(id) {
        return request.delete(`/admin/deleteById/${id}`)
    },
    deleteAll(ids) {
        return request.delete(`/admin/deleteAll/${ids}`)
    },
    add(admin) {
        //admin以JSON形式传递到后台
        return request.post('/admin/add', admin)
    },
    selectById(id) {
        return request.get(`/admin/selectById/${id}`)
    },
    update(admin) {
        return request.put('/admin/update', admin)
    },
    login(admin) {
        return request.post('/admin/login', admin)
    },
    adminInfo() {
        return request.get(`/admin/adminInfo`)
    },
    updateStatus(id, status) {
        return request.put(`/admin/updateStatus/${id}/${status}`)
    },
    resetPassword(adminPassword) {
        return request.put('/admin/resetPassword', adminPassword)
    },
    selectAssignedRole(adminId) {
        return request.get(`/admin/selectAssignedRole/${adminId}`)
    },
    assignRole(adminId, roleIds) {
        return request.post(`/admin/assignRole`, null, {params: {adminId, roleIds}});
    }
}

export default adminApi